from rest_framework import serializers
from .models import Blog


class BlogSerializers(serializers.ModelSerializer):
    labels = serializers.StringRelatedField(many=True)
    creator = serializers.StringRelatedField(many=False)

    class Meta:
        model = Blog
        fields = ('title', 'labels', 'creator', 'pub_date', 'last_update_date', 'content', 'html', 'richText')


class BlogListSerializers(serializers.ModelSerializer):
    labels = serializers.StringRelatedField(many=True)
    creator = serializers.StringRelatedField(many=False)

    class Meta:
        model = Blog
        fields = ('id', 'title', 'labels', 'creator', 'pub_date', 'last_update_date')
